var bindEvent = function(dom, type, fn){
	if(dom.addEventListener){
		dom.addEventListener(type, fn, false);
	}else if(dom.attachEvent){
		dom.attachEvent('on' + type, fn);
	}else{
		dom['on' + type] = fn;
	}
}
// var demo = document.getElementById('demo');
// bindEvent(demo, 'click', function(){
// 	this.style.background = 'red';
// });
function bindEvent(dom, type, fn, data){
	var data = data || {};
	dom.attachEvent('on' + type, function(e){
		fn.call(dom, e, data);
	});
}
function $(id){return document.getElementById('id')};
bindEvent($('bin'), 'click', function(e, d){
	$('test').innerHTML = e.type + d.text + this.tagName;
}, {text : 'test demo'});

var Visitor = (function(){
	return {
		splice : function(){
			var args = Array.prototype.splice.call(arguments, 1);
			return Array.prototype.splice.apply(arguments[0], args);
		},
		push : function(){
			var len = arguments[0].length || 0;
			var args = this.splice(arguments, 1);
			arguments[0].length = len + arguments.length - 1;
			return Array.prototype.push.apply(arguments[0], args);
		},
		pop : function(){
			return Array.prototype.pop.apply(arguments[0]);
		}
	}
})();

var a = new object();
console.log(a.length);
Visitor.push(a, 1, 2, 3, 4);
console.log(a.length);
Visitor.push(a, 4, 5, 6);
console.log(a);
console.log(a.length);
Visitor.pop(a);
console.log(a);
console.log(a.length);
Visitor.splice(a,2);
console.log(a);